/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/


#include "stdafx.h"
#include <pgl/core/pgl.h>
#include <pgl/core/PGLPieData.h>
#include <pgl/core/PGLRegion.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


PGL_IMPLEMENT_DYNCREATE(CPGLPieData, CPGLObject);

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

void CPGLPieData::SerializeXML(CPGLArchive& ar)
{
	static const TCHAR szTag[] = _T("CPGLPieData");

	markup::CMarkupArchive& xml = *((markup::CMarkupArchive*)ar.GetMarkup());
	if(ar.IsStoring())
	{
		xml.AddChildElem(szTag);
		xml.AddChildAttrib(_T("Name"),GetName());
		xml.IntoElem();

			/////////////////////////////////////////////////////////
			// Adding base class
			CPGLObject::SerializeXML(ar);

			xml.AddChildElemEx(_T("Value"),m_dValue);
			xml.AddChildElemEx(_T("Exploded"),m_bExploded);
		xml.OutOfElem();
	}
	else
	{
		if  (!xml.FindChildElem(szTag))
				return;

		xml.IntoElem();
			/////////////////////////////////////////////////////////
			// Adding base class
			CPGLObject::SerializeXML(ar);

			xml.FindGetChildData(_T("Value"), m_dValue);
			xml.FindGetChildData(_T("Exploded"), m_bExploded);
		xml.OutOfElem();
	}
}

#ifdef _DEBUG
void CPGLPieData::Dump( CDumpContext& dc ) const
{
    // call base class function first
    CPGLObject::Dump( dc );

    // now do the stuff for our specific class
	dc << _T("CPGLPieData ID ") << GetID() << "\n";
}
void CPGLPieData::AssertValid() const
{
    // call inherited AssertValid first
    CPGLObject::AssertValid();

} 
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPGLPieData::CPGLPieData(double dValue, bool bExploded)
: m_dValue(dValue), m_bExploded(bExploded)
{
}

CPGLPieData& CPGLPieData::operator = (const CPGLPieData& p)
{
	if (this != &p)
	{
		this->CPGLObject::operator =(p);

		m_dValue = p.m_dValue;
		m_bExploded = p.m_bExploded;
	}

	return *this;
}
